package com.aspose.cells;

public class Font {
   byte a;
   zakp b;
   WorksheetCollection c;
   private Object f;
   private int g;
   private int h = 0;
   private short i = 400;
   byte d;
   String e;
   private int j = -1;
   private int k;
   private short l;
   private static final com.aspose.cells.b.c.a.za m = new com.aspose.cells.b.c.a.za(new String[]{"major", "minor", "none", "隶书", "宋体", "黑体", "HGS行書体", "B Traffic", "B Nazanin", "Narkisim", "Wingdings", "Berlin Sans FB Demi", "Aharoni", "Brush Script MT", "Monotype Corsiva"});

   String a() {
      switch(this.k()) {
      case 1:
         return "major";
      case 2:
         return "minor";
      default:
         return null;
      }
   }

   void a(String var1) {
      if (var1 != null && !"".equals(var1)) {
         switch(m.a(var1.toLowerCase())) {
         case 0:
            this.e(1);
            break;
         case 1:
            this.e(2);
            break;
         case 2:
            this.e(0);
         }
      } else {
         this.e(0);
      }

   }

   public int getCharset() {
      return this.a;
   }

   public void setCharset(int value) {
      this.a = (byte)value;
      this.g(15);
   }

   int b() {
      if (this.b.a()) {
         return 32767;
      } else {
         boolean var1 = false;
         boolean[] var2 = new boolean[]{var1};
         int var3 = this.b.a(this.c, 32767, var2);
         var1 = var2[0];
         return var3;
      }
   }

   Font(WorksheetCollection sheets, Object format, boolean isShape) {
      if (sheets != null) {
         if (sheets.z().size() == 0) {
            this.e = sheets.n().getSettings().o();
            this.g = sheets.n().getSettings().p();
         } else {
            Font var4 = (Font)sheets.z().get(0);
            this.e = var4.getName();
            this.g = var4.g;
         }

         this.c = sheets;
      } else {
         this.e = "Arial";
         this.g = 200;
      }

      this.f = format;
      this.b = new zakp(isShape);
      this.b.a(true);
      this.d = 2;
   }

   Object c() {
      return this.f;
   }

   void a(Object var1) {
      this.f = var1;
   }

   boolean d() {
      return this.f != null && this.f instanceof zbi;
   }

   public boolean isItalic() {
      return (this.k & 4) != 0;
   }

   public void setItalic(boolean value) {
      if (value) {
         this.k |= 4;
      } else {
         this.k &= -5;
      }

      this.g(18);
   }

   public boolean isBold() {
      return this.i >= 700;
   }

   public void setBold(boolean value) {
      if (value) {
         this.i = 700;
      } else {
         this.i = 400;
      }

      this.g(17);
   }

   void a(boolean var1) {
      if (var1) {
         this.i = 700;
      } else {
         this.i = 400;
      }

   }

   public int getCapsType() {
      switch((this.k & 96) >> 5) {
      case 0:
         return 0;
      case 1:
         return 2;
      case 2:
         return 1;
      default:
         return 0;
      }
   }

   public void setCapsType(int value) {
      this.k &= -97;
      switch(value) {
      case 0:
      default:
         break;
      case 1:
         this.k |= 64;
         break;
      case 2:
         this.k |= 32;
      }

   }

   public int getStrikeType() {
      switch((this.k & 24) >> 3) {
      case 0:
         return 2;
      case 1:
         return 0;
      case 2:
         return 1;
      default:
         return 2;
      }
   }

   public void setStrikeType(int value) {
      this.k &= -25;
      switch(value) {
      case 0:
         this.k |= 8;
         break;
      case 1:
         this.k |= 16;
      case 2:
      }

      this.g(20);
   }

   public boolean isStrikeout() {
      return this.getStrikeType() == 0;
   }

   public void setStrikeout(boolean value) {
      if (value) {
         this.setStrikeType(0);
      } else if (this.getStrikeType() == 0) {
         this.setStrikeType(2);
      } else {
         this.g(20);
      }

   }

   byte e() {
      if (this.h < 0) {
         return 2;
      } else {
         return (byte)(this.h > 0 ? 1 : 0);
      }
   }

   int f() {
      return this.h;
   }

   void a(int var1) {
      this.h = var1;
      this.g(23);
   }

   public double getScriptOffset() {
      return (double)this.h / (double)zml.k * 100.0D;
   }

   public void setScriptOffset(double value) {
      this.h = (int)(value / 100.0D * (double)zml.k);
      this.g(23);
   }

   public boolean isSuperscript() {
      return this.h > 0;
   }

   public void setSuperscript(boolean value) {
      if (value) {
         if (this.h <= 0) {
            this.h = 30 * zml.k / 100;
         }
      } else if (this.h > 0) {
         this.h = 0;
      }

      this.g(23);
   }

   public boolean isSubscript() {
      return this.h < 0;
   }

   public void setSubscript(boolean value) {
      if (value) {
         if (this.h >= 0) {
            this.h = -25 * zml.k / 100;
         }
      } else if (this.h < 0) {
         this.h = 0;
      }

      this.g(23);
   }

   int g() {
      return this.i;
   }

   void b(int var1) {
      if (var1 >= 0 && var1 <= 900) {
         if (var1 == 0) {
            this.i = 400;
         } else {
            this.i = (short)(var1 / 100 * 100);
         }

         this.g(17);
      }
   }

   public int getUnderline() {
      return (this.k & 126976) >> 12;
   }

   public void setUnderline(int value) {
      byte var2 = (byte)value;
      this.k &= -126977;
      this.k |= (var2 & 255) << 12;
      this.g(19);
   }

   byte h() {
      return this.d;
   }

   void a(byte var1) {
      this.d = var1;
      this.g(14);
   }

   public String getName() {
      return this.e;
   }

   public void setName(String value) {
      this.e = value;
      this.g(13);
      this.d(this.e);
      this.e(0);
   }

   void b(String var1) {
      this.e = var1;
      this.g(13);
      this.d(this.e);
   }

   void c(String var1) {
      this.e = var1;
      this.d(this.e);
   }

   void a(String var1, int var2) {
      this.e = var1;
      this.g(13);
      this.d(this.e);
      this.e(var2);
   }

   private void d(String var1) {
      switch(m.a(this.e)) {
      case 3:
      case 4:
      case 5:
         this.a = -122;
         break;
      case 6:
         this.a = -128;
         this.d = 4;
         break;
      case 7:
      case 8:
         this.a = -78;
         break;
      case 9:
         this.a = -79;
         break;
      case 10:
         this.a = 2;
         break;
      default:
         this.a = 0;
      }

   }

   public double getDoubleSize() {
      return (double)(this.g & '\uffff') / 20.0D;
   }

   public void setDoubleSize(double value) {
      if (value >= 1.0D && value <= 409.0D) {
         this.g = (int)(value * 20.0D);
         this.g(12);
      } else {
         throw new CellsException(6, "Font size is out of range.");
      }
   }

   public int getSize() {
      return (short)((this.g & '\uffff') / 20);
   }

   public void setSize(int value) {
      if (value >= 1 && value <= 409) {
         this.g = value * 20;
         this.g(12);
      } else {
         throw new CellsException(6, "Font size is out of range.");
      }
   }

   void a(double var1) {
      this.g = (int)(var1 * 20.0D);
   }

   int i() {
      return this.g;
   }

   void c(int var1) {
      this.g = var1;
      this.g(12);
   }

   public ThemeColor getThemeColor() {
      if (this.b.b() == 4) {
         int var1 = zsk.c(this.b.d());
         return new ThemeColor(var1, this.b.f());
      } else {
         return null;
      }
   }

   public void setThemeColor(ThemeColor value) {
      if (value == null) {
         this.b.a(true);
      } else {
         this.b.a(4, zsk.d(value.getColorType()));
         this.b.a(value.getTint());
         this.g(16);
      }

   }

   public Color getColor() {
      return this.b.a() ? Color.getBlack() : this.b.b(this.c == null ? null : this.c.n());
   }

   public void setColor(Color value) {
      if (com.aspose.cells.a.c.zh.a(value)) {
         this.b.a(true);
      } else {
         this.b.a(2, value.toArgb());
      }

      this.b.e();
      this.g(16);
   }

   public int getArgbColor() {
      return this.getColor().toArgb();
   }

   public void setArgbColor(int value) {
      this.setColor(Color.fromArgb(value));
   }

   public boolean equals(Font font) {
      return this.b.a(font.b) && this.g == font.g && com.aspose.cells.b.a.zv.b(this.e, font.e) && this.k == font.k && this.i == font.i;
   }

   boolean a(Font var1) {
      return this.b.a(var1.b) && this.g == var1.g && com.aspose.cells.b.a.zv.b(this.e, var1.e) && this.k == var1.k && this.i == var1.i && this.h == var1.h;
   }

   boolean b(Font var1) {
      return this.b.a(var1.b) && this.g == var1.g && com.aspose.cells.b.a.zv.b(this.e, var1.e) && this.k == var1.k && this.l == var1.l && this.i == var1.i && this.h == var1.h;
   }

   boolean a(Font var1, Workbook var2, Workbook var3) {
      return this.b.a(var1.b, var2, var3) && this.g == var1.g && com.aspose.cells.b.a.zv.b(this.e, var1.e) && this.k == var1.k && this.i == var1.i && this.h == var1.h;
   }

   void c(Font var1) {
      this.a = var1.a;
      if (this.c != var1.c && var1.b.b() == 3) {
         this.b.a(2, var1.b.c(var1.c.n()));
      } else {
         this.b.f(var1.b);
      }

      this.d = var1.d;
      this.g = var1.g;
      this.e = var1.e;
      this.l = var1.l;
      this.k = var1.k;
      this.i = var1.i;
      this.j = var1.j;
      this.h = var1.h;
   }

   int j() {
      return this.j;
   }

   void d(int var1) {
      this.j = var1;
   }

   public boolean isNormalizeHeights() {
      return (this.k & 131072) != 0;
   }

   public void setNormalizeHeights(boolean value) {
      if (value) {
         this.k |= 131072;
      } else {
         this.k &= -131073;
      }

   }

   int k() {
      switch(this.k >> 7 & 3) {
      case 0:
         return 0;
      case 1:
         return 1;
      case 2:
         return 2;
      default:
         return 0;
      }
   }

   void e(int var1) {
      byte var2 = 0;
      switch(var1) {
      case 1:
         var2 = 1;
         break;
      case 2:
         var2 = 2;
      }

      this.k &= -385;
      if (var2 != 0) {
         this.k |= var2 << 7;
         this.g(39);
      }

   }

   void l() {
      this.l = 0;
   }

   void d(Font var1) {
      if (var1.f(13)) {
         this.b(var1.e);
      }

      if (var1.f(12)) {
         this.setSize(var1.getSize());
      }

      if (var1.f(16)) {
         this.b.f(var1.b);
         this.g(16);
      }

      if (var1.f(18)) {
         this.setItalic(var1.isItalic());
      }

      if (var1.f(20)) {
         this.setStrikeout(var1.isStrikeout());
      }

      if (var1.f(23)) {
         this.a(var1.f());
      }

      if (var1.f(19)) {
         this.setUnderline(var1.getUnderline());
      }

      if (var1.f(17)) {
         this.b(var1.g());
      }

   }

   void a(StringBuilder var1) {
      var1.append(Byte.toString(this.a));
      var1.append(com.aspose.cells.b.a.zr.a(this.getColor()));
      var1.append(Byte.toString(this.d));
      var1.append(Integer.toString(this.g));
      var1.append(com.aspose.cells.b.a.zo.a(this.k));
      var1.append(this.e);
      var1.append(Short.toString(this.i));
   }

   void a(byte[] var1) {
      this.g = com.aspose.cells.b.a.zc.e(var1, 0);
      this.g(12);
      int var2 = var1[2] & 255 & 1;
      if (var2 == 1) {
         this.i = 700;
      } else {
         this.i = 400;
      }

      var2 = var1[2] & 255 & 2;
      this.setItalic(var2 != 0);
      var2 = var1[2] & 255 & 8;
      this.setStrikeout(var2 != 0);
      int var3 = com.aspose.cells.b.a.zc.e(var1, 4) & '\uffff';
      if (var3 < 64 && var3 >= 0) {
         this.b.a(3, var3);
      } else {
         this.b.a(true);
      }

      this.b(com.aspose.cells.b.a.zc.e(var1, 6));
      switch(var1[8]) {
      case 0:
      default:
         break;
      case 1:
         this.setSuperscript(true);
         break;
      case 2:
         this.setSubscript(true);
      }

      switch(var1[10]) {
      case 1:
         this.setUnderline(1);
         break;
      case 2:
         this.setUnderline(2);
         break;
      case 33:
         this.setUnderline(3);
         break;
      case 34:
         this.setUnderline(4);
         break;
      default:
         this.setUnderline(0);
      }

      this.d = var1[11];
      this.a = var1[12];
      switch(var1[15]) {
      case 0:
         this.e = Encoding.getASCII().a(var1, 16, var1[14] & 255);
         break;
      case 1:
         this.e = Encoding.getUnicode().a(var1, 16, (var1[14] & 255) * 2);
         break;
      default:
         int var4 = var1[14] & 255;
         if (var4 + 16 > var1.length) {
            var4 = var1.length - 16;
         }

         this.e = Encoding.getASCII().a(var1, 16, var4);
      }

      switch(m.a(this.e)) {
      case 11:
      case 12:
         this.i = 700;
         break;
      case 13:
      case 14:
         this.setItalic(true);
      }

   }

   boolean f(int var1) {
      switch(var1) {
      case 11:
         return this.l != 0;
      case 12:
         return (this.l & 256) != 0;
      case 13:
         return (this.l & 128) != 0;
      case 14:
         return (this.l & 2) != 0;
      case 15:
         return (this.l & 4) != 0;
      case 16:
         return (this.l & 512) != 0;
      case 17:
         return (this.l & 1024) != 0;
      case 18:
         return (this.l & 2048) != 0;
      case 19:
         return (this.l & 8192) != 0;
      case 20:
         return (this.l & 4096) != 0;
      case 21:
         if ((this.l & 1) != 0) {
            return this.isSubscript();
         }

         return false;
      case 22:
         if ((this.l & 1) != 0) {
            return this.isSuperscript();
         }

         return false;
      case 23:
         return (this.l & 1) != 0;
      case 24:
      case 25:
      case 26:
      case 27:
      case 28:
      case 29:
      case 30:
      case 31:
      case 32:
      case 33:
      case 34:
      case 35:
      case 36:
      case 37:
      case 38:
      default:
         return false;
      case 39:
         return (this.l & 8) != 0;
      case 40:
         return (this.l & 16) != 0;
      case 41:
         return (this.l & 32) != 0;
      case 42:
         return (this.l & 64) != 0;
      }
   }

   void g(int var1) {
      switch(var1) {
      case 12:
         this.l = (short)(this.l | 256);
         break;
      case 13:
         this.l = (short)(this.l | 128);
         break;
      case 14:
         this.l = (short)(this.l | 2);
         break;
      case 15:
         this.l = (short)(this.l | 4);
         break;
      case 16:
         this.l = (short)(this.l | 512);
         break;
      case 17:
         this.l = (short)(this.l | 1024);
         break;
      case 18:
         this.l = (short)(this.l | 2048);
         break;
      case 19:
         this.l = (short)(this.l | 8192);
         break;
      case 20:
         this.l = (short)(this.l | 4096);
      case 21:
      case 22:
      case 24:
      case 25:
      case 26:
      case 27:
      case 28:
      case 29:
      case 30:
      case 31:
      case 32:
      case 33:
      case 34:
      case 35:
      case 36:
      case 37:
      case 38:
      default:
         break;
      case 23:
         this.l = (short)(this.l | 1);
         break;
      case 39:
         this.l = (short)(this.l | 8);
         break;
      case 40:
         this.l = (short)(this.l | 16);
         break;
      case 41:
         this.l = (short)(this.l | 32);
         break;
      case 42:
         this.l = (short)(this.l | 64);
      }

      if (this.f != null) {
         if (this.f instanceof Style) {
            Style var2 = (Style)this.f;
            if (!var2.k()) {
               var2.d(true);
            }
         } else if (this.f instanceof zbi) {
            zbi var3 = (zbi)this.f;
            switch(var1) {
            case 12:
            case 14:
            case 17:
            case 18:
               var3.a(this.getSize());
            case 13:
            case 15:
            case 16:
            }
         }
      }

   }

   int m() {
      int var1 = (this.isBold() ? 1 : 0) | (this.isItalic() ? 2 : 0) | (this.isStrikeout() ? 8 : 0) | (this.getUnderline() != 0 ? 4 : 0);
      return var1;
   }

   public String toString() {
      StringBuilder var1 = new StringBuilder();
      var1.append("Aspose.Cells.Font [ ");
      var1.append(this.e);
      var1.append("; " + this.getDoubleSize());
      if (!this.isBold() && !this.isItalic()) {
         var1.append("; Regular");
      } else {
         if (this.isBold()) {
            var1.append("; Bold");
         }

         if (this.isItalic()) {
            var1.append("; Italic");
         }
      }

      if (this.getUnderline() != 0) {
         switch(this.getUnderline()) {
         case 1:
            var1.append("; Underline");
            break;
         case 2:
            var1.append("; Double Underline");
            break;
         case 3:
            var1.append("; Accounting Underline");
            break;
         case 4:
            var1.append("; Double Accounting Underline");
         }
      }

      var1.append("; " + this.getColor());
      var1.append(" ]");
      return com.aspose.cells.b.a.zr.a(var1);
   }
}
